from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver import Remote

from base.authorize_base import Authorize_base


class AuthorizePage(Authorize_base):  #
    def privacy_agree_button_click(self, driver: Remote):  # 隐私政策同意
        privacy_agree_button_xpath = self.privacy_agree_button()
        # return driver.find_element(AppiumBy.XPATH, privacy_agree_button_xpath).click()
        return self.click_new(driver, AppiumBy.XPATH, privacy_agree_button_xpath)

    def authorize_agree_button_click(self, driver: Remote):  # 设备信息授权同意
        authorize_agree_button_xpath = self.authorize_agree_button()
        return self.click_new(driver, AppiumBy.XPATH, authorize_agree_button_xpath)

    def ad_close_button_click(self, driver: Remote):  # 关闭页面广告
        ad_close_button_xpath = self.ad_close_button()
        return self.click_new(driver, AppiumBy.XPATH, ad_close_button_xpath)

    def authorize_setup(self, driver: Remote):
        self.privacy_agree_button_click(driver)
        self.authorize_agree_button_click(driver)
        self.ad_close_button_click(driver)

    def authorize_assert(self, driver, img_name):
        """
          访问首页后判断图书标签
            :param driver:
            :param img_name:
            :return:
            """
        return self.find_img_in_source(driver, img_name)
